package com.tiger.web.controller.project;


import com.tiger.common.annotation.Log;
import com.tiger.common.core.controller.BaseController;
import com.tiger.common.core.domain.AjaxResult;
import com.tiger.common.core.domain.model.LoginUser;
import com.tiger.common.core.page.TableDataInfo;
import com.tiger.common.enums.BusinessType;
import com.tiger.common.utils.ServletUtils;
import com.tiger.common.utils.spring.SpringUtils;
import com.tiger.framework.web.service.TokenService;
import com.tiger.project.domain.ProjectAcceptance;
import com.tiger.project.service.IProjectAcceptanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;

import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 【请填写功能名称】Controller
 *
 * @author standard
 * @date 2022-09-19
 */
@Api(tags = "项目验收")
@RestController
@RequestMapping("/system/acceptance")
public class ProjectAcceptanceController extends BaseController {
    @Autowired
    private IProjectAcceptanceService projectAcceptanceService;

    /**
     * 查询【项目验收】列表
     */
    @ApiOperation(value = "查询【项目验收】列表")
    //@PreAuthorize("@ss.hasPermi('system:acceptance:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectAcceptance projectAcceptance) {
        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
        projectAcceptance.setCompanyId(loginUser.getUser().getDeptId());
        startPage();
        List<ProjectAcceptance> list = projectAcceptanceService.selectProjectAcceptanceList(projectAcceptance);
        return getDataTable(list);
    }



    /**
     * 获取【项目验收】详细信息
     */
    @ApiOperation(value = "获取【项目验收】列详细信息")
    //@PreAuthorize("@ss.hasPermi('system:acceptance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(projectAcceptanceService.selectProjectAcceptanceById(id));
    }

    /**
     * 新增【项目验收】
     */
//    @ApiOperation(value = "验收")
//    @PreAuthorize("@ss.hasPermi('system:acceptance:add')")
//    @Log(title = "【项目验收】", businessType = BusinessType.INSERT)
//    @PostMapping("/add")
//    public AjaxResult add(@RequestBody ProjectAcceptance projectAcceptance) {
//
//        return toAjax(projectAcceptanceService.insertProjectAcceptance(projectAcceptance));
//    }

    /**
     * 修改【项目验收】
     */
    @ApiOperation(value = "【项目验收】")
    //@PreAuthorize("@ss.hasPermi('system:acceptance:edit')")
//    @Log(title = "【项目验收】", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody ProjectAcceptance projectAcceptance) {
        return toAjax(projectAcceptanceService.updateProjectAcceptance(projectAcceptance));
    }

    /**
     * 删除【项目验收】
     */
    @ApiOperation(value = "删除【项目验收】")
    //@PreAuthorize("@ss.hasPermi('system:acceptance:remove')")
//    @Log(title = "【项目验收】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id) {
        return toAjax(projectAcceptanceService.deleteProjectAcceptanceById(id));
    }

    @ApiOperation(value = "审核回调【项目验收】")
    //@PreAuthorize("@ss.hasPermi('system:acceptance:edit')")
//    @Log(title = "【项目验收】", businessType = BusinessType.UPDATE)
    @GetMapping("/callBack")
    public AjaxResult callBack(@ApiParam(value = "项目验收id") Long id,
                               @ApiParam(value = "审核状态 4-审批通过，5-已驳回") Long status,String oaFile) {
        return toAjax(projectAcceptanceService.callBack(id,status,oaFile));
    }
}
